﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//发射炮弹
public class Shoot : MonoBehaviour
{
    public GameObject bullet;
    public float Speed = 5;


    
    void Start()
    {
        
    }


    void Update()
    {
        //当按下了鼠标左键
        if (Input.GetMouseButtonDown(0))
        {
           GameObject b = GameObject.Instantiate(bullet, transform.position, transform.rotation);//实例化子弹
            Rigidbody rgd = b.GetComponent<Rigidbody>();
            rgd.velocity = transform.forward * Speed;//forward(0,0,1)
        }
    }
}
